package com.ysu.his.admin.controller;

import com.github.pagehelper.PageInfo;
import com.ysu.his.admin.service.RegisterLevelService;
import com.ysu.his.dto.RegisterLevelDto;
import com.ysu.his.entity.registration.RegistrationLevel;
import com.ysu.his.vo.RegisterLevelVo;
import com.ysu.his.vo.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/admin/register")
public class RegisterLevelController
{

    @Autowired
    private RegisterLevelService registerLevelService;

    @GetMapping(value = "/getRegisterLevelByPage/{page}/{limit}")
    public Result getRegisterLevelByPage(@PathVariable("page") Integer page,
                                         @PathVariable("limit") Integer limit,
                                         RegisterLevelDto registerLevelDto)
    {

        PageInfo<RegisterLevelVo> pageInfo = registerLevelService.getRegisterLevelByPage(page,limit,registerLevelDto);
        return Result.ok(pageInfo);
    }

    @PostMapping(value = "/addRegisterLevel")
    public Result addRegisterLevel(@RequestBody RegistrationLevel registrationLevel)
    {
        registerLevelService.addRegisterLevel(registrationLevel);
        return Result.ok(null);
    }

    @PutMapping(value = "/updateRegisterLevelById")
    public Result updateRegisterLevel(@RequestBody RegistrationLevel registrationLevel)
    {
        //除了id都可以改
        registerLevelService.updateRegisterLevel(registrationLevel);
        return Result.ok(null);
    }

}
